export {};

const arr = ['a', 'b', 'c'];
// arr.forEach 第一个参数的类型为： (value: string, index: number, array: string[]) => void

arr.forEach(() => {
  console.log('===');
});
arr.forEach((item) => {
  console.log(item);
});
arr.forEach((item, index) => {
  console.log(item, index);
});
arr.forEach((item, index, arr) => {
  console.log(item, index, arr);
});

arr.forEach((item, index, arr) => {
  console.log(item, index, arr);
});

// 等价于
let fn = (value: string, index: number, array: string[]): void => {
  console.log(value, index, array);
};

const fn1 = (): void => {};
const fn2 = (a: string): string => {
  return a;
};
const fn3 = (a: string, b: number): void => {};
const fn4 = (a: string, b: number, c: string[], d: string): void => {};

fn = fn1;
fn = fn2;
fn = fn3;
// fn = fn4 // 无法兼容，接收方，只能处理 3个参数，给我4个，处理不了。
